include include.mk

includePATH = include
buildPATH 	= build
libcPATH 	= libc

SOURCE_FILES := $(shell find -name "*.[cS]")
SRC := $(patsubst ./%, $(buildPATH)/%.o, $(SOURCE_FILES))

all: build

$(buildPATH)/%.S.o: %.S
	@mkdir -p $(@D)
	@echo " BUILD: $<"
	@$(AS) $(ASFLAG) -I$(includePATH) $< -o $@

$(buildPATH)/%.c.o: %.c
	@mkdir -p $(@D)
	@echo " BUILD: $<"
	@$(CC) $(CFLAG) -I$(includePATH) $< -o $@

main: $(SRC)
	@echo " BUILD: $@"
	@$(LD) $(LDFLAG) $+ -o $(buildPATH)/$@

clean:
	@rm -rf ./build ./*/*.o 
	
build: clean main
	@echo Done!!!

run:
	@qemu-system-i386 $(QEMU_OPTIONS)
	@sleep 0.5